import React,{Component} from "react";
import './Header.scss'


class Header extends Component{
    state={
        title:'',
        desc:''
    }
    handleTitle=(e)=>{
        this.setState({
            title:e.target.value
        })
    }

    updateContent=(e)=>{
        this.setState({
            desc:e.target.value
        })
    }

    // 发表评论
    publish=()=>{
        const {title,desc}=this.state
        this.props.updateList({title,desc})
        this.setState({
            title:'',
            desc:""
        })
    }
        render(){
            return(<>
            <div className="Box">
                    <div className="box">
        </div>
            <div className="center">
            <div className="inputA">
                <input type="text" value={this.state.title} className="inputhd" placeholder='请输入评论人' onChange={this.handleTitle} />
            </div>
            <div className="inputB">
                <textarea  cols="40" value={this.state.desc} rows="10" placeholder='请输入评论内容' onChange={this.updateContent}></textarea>
            </div>
            <button onClick={this.publish}>发表评论</button>
            </div>
            </div>

            </>)
        }
}



export default Header